#pragma once

#ifndef VTTPACKNODE_H
#define VTTPACKNODE_H

#include "VTTObject.h"

/**
  *	Class that is used to pack the images into the Virtual Texture Atlas.
  */
class VTTPackNode : public VTTObject
{

public:
	VTTPackNode( UINT32 width, UINT32 height );
	VTTPackNode( UINT32 xMin, UINT32 yMin, UINT32 xMaxExclusive, UINT32 yMaxExclusive );
	VTTPackNode( const VTTPackNode &vttPackNode );

	~VTTPackNode( void );

	const UINT32 *GetArea( void ) const;
	UINT32 GetHeight( void ) const;
	UINT32 GetWidth( void ) const;

	const VTTPackNode *Insert( UINT32 width, UINT32 height );

	VTTPackNode &operator=( const VTTPackNode &vttPackNode );

private:
	/** The whole area of the pack node in the order x_min, y_min, x_max + 1, y_max + 1 */
	UINT32 mArea[4];
	/** The children of the pack node, in index 0 there is the area to the right of the used area, in index 1 there is the area below the used area and the "index 0"-child */
	VTTPackNode *mChildren[2];
	/** The directly used area of the pack node. This is the area where exactly one image relies */
	VTTPackNode *mUsedArea;
	/** Number of pack node objects currently in memory */
	static UINT32 objectCount;
};

#endif